#include<iostream>
#include<signal.h>
#include<unistd.h>
using namespace std;
void handler(int sig)
{    
    while(1)
    {
        sigset_t pending;
        sigpending(&pending);
        for (int i = 31; i > 0;i--)
        {
            if(sigismember(&pending,i))
            {
                cout << "1";
            }
            else
            cout << "0";
        }
        cout << endl;
        sleep(1);
    }
    
    cout << "get " << sig << endl;
    
}
int main()
{
    struct sigaction act, oact;
    act.sa_handler = handler;
    sigemptyset(&act.sa_mask);
    act.sa_flags = 0;
    sigaction(2, &act, &oact);
    while (1)
    {
        cout << "hello!" << endl;
        sleep(1);     
    }
    return 0;
}